package com.example.adminbase.service.imp;

import com.example.adminbase.dao.CrudDao;
import com.example.adminbase.dao.SysUserMapper;
import com.example.adminbase.domain.EncryptUtil;
import com.example.adminbase.domain.SysUser;
import com.example.adminbase.domain.UserQueryParam;
import com.example.adminbase.service.SysUserService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SysUserServiceImp implements SysUserService {

    /**
     * This is generated by MyBatis Generator, do not modify.
     * @mbg.generated
     */
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * This is generated by MyBatis Generator, do not modify.
     * @mbg.generated
     */
    @Override
    public CrudDao<String, SysUser> getDao() {
        return sysUserMapper;
    }

    @Override
    public Page<SysUser> findBy(UserQueryParam queryParam) {
        return (Page<SysUser>) sysUserMapper.findByQueryParam(queryParam);
    }

    @Override
    public void updatePassword(String id, String password) {
        SysUser user = new SysUser();
        user.setUserId(id);
        user.setPassword(EncryptUtil.encryptPassword(password));
        sysUserMapper.updateSelective(user);
    }
}
